package AccionBoton;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ResourceBundle;

import javax.swing.JFileChooser;

import paginas.PaginaFuncionBoton;

public class AccionBuscarFichero implements ActionListener{

	
	JFileChooser fc;
	private PaginaFuncionBoton _frame;
	private int _documento = 0;
	
	
	public AccionBuscarFichero(PaginaFuncionBoton frame){
		
		_frame = frame;
		
	}
	
	public AccionBuscarFichero(PaginaFuncionBoton frame,int documento){
		
		_frame = frame;
		_documento = documento;
		
	}
	
	
    public void actionPerformed(ActionEvent e) {
        //Set up the file chooser.
        if (fc == null) {
            fc = new JFileChooser();
        }

        //Show it.
        int returnVal = fc.showDialog(_frame,ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_menu_mover_usuario_abrir"));

        //Process the results.
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            if(_documento==1){
                _frame.getTextoBuscarFichero().setText(file.getAbsolutePath());

            	
            }else{
                if(_documento==2){
                    _frame.getTextoBuscarAp().setText(file.getAbsolutePath());

                	
                }else{
                    if(_documento==3){
                        _frame.getTextoBuscarAplicacion().setText(file.getAbsolutePath());

                    	
                    }else{
            	
            _frame.getTextoBuscar().setText(file.getAbsolutePath());
                    }
                    }
            }
            _frame.pack();
            _frame.repaint();

        } else {
          
        }
       
        //Reset the file chooser for the next time it's shown.
        fc.setSelectedFile(null);
    }


	
	
	
}
